package leetcode.array;

import sun.security.util.Length;

/**
 * Created by xinxuchu on 2020/8/16.
 */
public class SelectInsertIndex {

    static public int searchInsert(int[] nums, int target) {

        if (target<nums[0]) return 0;
        if (target>nums[nums.length-1]) return nums.length;
        int index = 0;
        for (int i = 0; i <nums.length ; i++) {
            if (nums[i]<target){
                index = i+1;
            }
        }
        return index;
    }

    public static void main(String[] args) {
        int[] nums = new int[]{1,3,5,6};
        System.out.println(searchInsert(nums,5));
    }

}
